<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>OA开通</title>
	<link rel="shortcut icon" href="/images/user/favicon.png" type="image/x-icon">
    <script type="text/javascript" src="/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="/js/ajaxfileupload.js"></script>
    <style type="text/css">
		.progress { height: 20px; overflow: hidden; background-color: #f5f5f5; border-radius: 4px; -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); }
		.progress-bar { float: left; width: 0; height: 100%; font-size: 12px; line-height: 20px; color: #fff; text-align: center; background-color: #428bca; -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); -webkit-transition: width .6s ease; -o-transition: width .6s ease; transition: width .6s ease; }
		.progressbox { }
		.progressbox .progress-title { margin: 5px 0; font-size: 14px; text-align: center; }
    </style>
    <script>
    $(function(){
    	/* $.fn.extend({
			progress: function(data) {
				this.each(function(index, val) {
					var $this = $(this),
						$title = $this.find(".progress-title"),
						$progress = $this.find('.progress-bar');
					var title = data.title,
						progress = data.progress;
					try{
						$title.html(title);
						$progress.css({
							width: progress
						});
						$progress.text(progress);
					}catch(e){

					}
				});
			}
		});
    	var $progress = $(".progressbox");
    	
    	
    	$('#kt').on('click',function(){
			$.ajax({
				type:"POST",
				url:"/test/testOA",
				dataType:"json",
				success:function(data){
					
				}
			}) 
			
			var timer = setInterval(function(){
	    		$.ajax({
					type:"POST",
					url:"/test/getMsg",
					dataType:"json",
					success:function(data){
						var progress = data.progress;
						$progress.progress({progress: progress,title: data.title});
 						//alert("消息："+data);
						console.log("消息："+data.progress+"***"+data.title);
						if(progress == "100%"){
							clearInterval(timer);
							timer = null;
						}
					}
				});
	    		
    		},2000);
    	}) */
    	
    })
    
    function fileUpload() {
        $.ajaxFileUpload({
			url:"/upload/file?objectName=product",
			secureuri:false,
			fileElementId:"file",
			dataType:"json",
			success:function(data) {
				alert(data.message);
			},
			error:function (data, status, e) {
				BSTYUN.dialog.warn("图片上传失败,请重新选择图片！");
			}
		});
      }
    </script>
</head>

<body>
<!-- <input type="button" value="OA开通" id="kt"/> -->
<!-- <div class="progressbox">
		<h2 class="progress-title"></h2>
	    <div class="progress">
		  <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
		    0%
		  </div>
		</div>
	</div> -->
	<form>
      <input id="file" name="advImage" type="file" onchange="fileUpload()"/>
    </form>
</body>
</html>
